﻿package org.libspark.betweenas3.core.tweens
{
	import org.libspark.betweenas3.tweens.ITween;
	

	public class TweenDecorator extends AbstractTween
	{
		public function TweenDecorator(baseTween:IITween, position:Number)
		{
			super(baseTween.ticker, position);
			
			_baseTween = baseTween;
			_duration = baseTween.duration;
		}
		
		protected var _baseTween:IITween;
		
		public function get baseTween():IITween
		{
			return _baseTween;
		}
		

		override public function play():void 
		{
			if (!_isPlaying) {
				_baseTween.firePlay();
				super.play();
			}
		}
		

		override public function firePlay():void 
		{
			super.firePlay();
			_baseTween.firePlay();
		}
		

		override public function stop():void 
		{
			if (_isPlaying) {
				super.stop();
				_baseTween.fireStop();
			}
		}
		

		override public function fireStop():void 
		{
			super.fireStop();
			_baseTween.fireStop();
		}
		

		override protected function internalUpdate(time:Number):void 
		{
			_baseTween.update(time);
		}
	}
}